package StudyCode.summary.mycollection;

import java.util.*;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class HashSetUsedToRemoveDuplicateValuesFromArrayOfStrings {
	public static void main(String[] args) {
		String[] colors = {"red", "white", "blue", "green", "gray",
				"orange", "tan", "white", "cyan", "peach", "gray", "orange"};
		List<String> list = Arrays.asList(colors);
		System.out.printf("List: %s%n", list);

		printNonDuplicates(list);
	}

	private static void printNonDuplicates(Collection<String> values) {
		Set<String> set = new HashSet<>(values);

		System.out.printf("%n 不重复值是: ");

		for (String value : set)
			System.out.printf("%s ", value);

		System.out.println();
	}
}
